package com.zy.control;

import com.zy.entity.Book;
import com.zy.pojo.DocumentDTO;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@Api(value = "/swagger222", description = "主要swagger2操作",tags = "Swagger相关接口")
@RequestMapping("/swagger222")
@ApiResponses({
        @ApiResponse(code=200,message="成功",response= Book.class),
        @ApiResponse(code=400,message="用户输入错误",response=Book.class),
        @ApiResponse(code=500,message="系统内部错误",response=Book.class)
})
@Slf4j
public class Swagger2Controller {

    @PostMapping("/v1/documents")
    @ApiOperation(value = "文档注册", notes = "注册新的文档",httpMethod = "POST")
    public String upload(@RequestParam(value = "file", required = false) MultipartFile file, @RequestPart DocumentDTO documentDTO) {
        log.info("*****file : {}",file.getOriginalFilename());
        log.info("*****name : {}  num : {}",documentDTO.getName(),documentDTO.getNum());
        return "suc!!!";
    }

    @PostMapping("/v1/documents2")
    @ApiOperation(value = "文档注册", notes = "注册新的文档",httpMethod = "POST")
    public String upload2(@RequestParam(value = "file", required = false) MultipartFile file, @RequestPart DocumentDTO documentDTO) {
        log.info("*****file : {}",file.getOriginalFilename());
        log.info("*****name : {}  num : {}",documentDTO.getName(),documentDTO.getNum());
        return "suc!!!";
    }


}
